<template>
	<view class="wrapper" v-if="list.length > 0">
		<home-title @more="goMoreActivity" title="活动专区" :showMore="true"></home-title>
		<view class="swiperWrapper">
			<u-swiper height="100%" :list="list" keyName="image" indicator indicatorMode="dot" @click="goActivityDetail()"></u-swiper>
		</view>     
	</view>
</template>

<script>
	import homeTitle from '@/components/layout/home-title.vue'
	import {apiActivityList} from '@/api/marketing-api.js'
	import setting from '@/settings.js'
	export default {
		name: 'activity',
		components:{
		homeTitle 	
		},
		data() {
			return {
				list: [],
			}
		},
		props: {
			
		},
		mounted() {
           this.getActivity();
		},
		methods: {
            getActivity() {
				apiActivityList({
					tenantId : this.$store.state.user.tenantId,
					businessNo : this.$store.state.order.businessNo,
					pageNo : 1,
					pageSize: 5,
				}).then(res=> {
					this.list = res.data;
					for (let item of this.list) {
						item.image = setting.baseImageUrl + item.coverImage;
					}
				})
			},
			
			goActivityDetail(index) {
				console.log(index);
				let activity = this.list[index];
				let activityType = activity.activityType;
				var url = '';
				if(activityType == 1) {//秒杀活动
				    url = '/pagesB/activity/activityDetail-secondKill?bizNo=' + activity.activityId;
				}else if(activityType == 2) {//集客活动
					url = '/pagesB/activity/activityDetail-gather?bizNo=' + activity.activityId;
				}else if(activityType == 3) {//同行活动
					// url = '/pagesB/activity/activityDetail-peer';
		            this.$u.toast('同行活动');
				}else if(activityType == 4) {//抽奖活动
					// url = '/pagesB/activity/activityDetail-sweepstakes';
					this.$u.toast('抽奖活动');
				}
				uni.navigateTo({
					url: url
				})
			},
			goMoreActivity() {
				console.log('活动');
				uni.navigateTo({
					url: '/pagesB/activity/home-moreActivity'
				})
			}
			
			
		}
		
	}
</script>

<style lang="scss" scoped>
	.wrapper {
	   
	}
	.swiperWrapper {
		height: 260upx;
		width: 706upx;	
	}
</style>
